package com.ysx.teacher.day20210906;

import java.util.Scanner;

public class Ch01 {

    public static void main(String[] args) {
        //  13231

        // 方法

        String string="13231";

        boolean flag =check(string);

        if(flag==true){
            System.out.println(string +"是1个回文数");
        }else{
            System.out.println(string +"不是1个回文数");
        }
    }

    public static boolean check(String str){

        boolean result= false;

        char[] chars = str.toCharArray();

        int len=chars.length;

        System.out.println("数组的长度:"+len);

        int counter=len/2;
        System.out.println("循环的次数"+counter);

        // 0 1

        int cishu=0;
        for(int index=0;index<counter;index++){

            //分析
            if(chars[index]== chars[len-1-index]){
                cishu++;
            }else{
                result=false;
                break;
            }
        }

        if(cishu == counter){
            result=true;
        }else{
            result=false;
        }

        return  result;
    }
}
